@dcl/content-validator 4.2.4-4064084886.commit-5f698c4 → 4.2.4-4135566596.commit-6ae9fb8
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validations/ADR45.d.ts +2 -2
- package/dist/validations/ADR45.d.ts.map +1 -1
- package/dist/validations/ADR45.js +7 -8
- package/dist/validations/ADR45.js.map +1 -1
- package/dist/validations/access-checker/access.d.ts +2 -2
- package/dist/validations/access-checker/access.d.ts.map +1 -1
- package/dist/validations/access-checker/access.js +15 -17
- package/dist/validations/access-checker/access.js.map +1 -1
- package/dist/validations/access-checker/emotes.d.ts +2 -2
- package/dist/validations/access-checker/emotes.d.ts.map +1 -1
- package/dist/validations/access-checker/emotes.js +7 -8
- package/dist/validations/access-checker/emotes.js.map +1 -1
- package/dist/validations/access-checker/items/collection-asset.js +2 -2
- package/dist/validations/access-checker/items/collection-asset.js.map +1 -1
- package/dist/validations/access-checker/items/items.d.ts +1 -3
- package/dist/validations/access-checker/items/items.d.ts.map +1 -1
- package/dist/validations/access-checker/items/items.js +23 -24
- package/dist/validations/access-checker/items/items.js.map +1 -1
- package/dist/validations/access-checker/profiles.d.ts +6 -6
- package/dist/validations/access-checker/profiles.d.ts.map +1 -1
- package/dist/validations/access-checker/profiles.js +59 -61
- package/dist/validations/access-checker/profiles.js.map +1 -1
- package/dist/validations/access-checker/scenes.d.ts +2 -2
- package/dist/validations/access-checker/scenes.d.ts.map +1 -1
- package/dist/validations/access-checker/scenes.js +216 -216
- package/dist/validations/access-checker/scenes.js.map +1 -1
- package/dist/validations/access-checker/stores.d.ts +2 -2
- package/dist/validations/access-checker/stores.d.ts.map +1 -1
- package/dist/validations/access-checker/stores.js +14 -15
- package/dist/validations/access-checker/stores.js.map +1 -1
- package/dist/validations/access-checker/wearables.d.ts +2 -2
- package/dist/validations/access-checker/wearables.d.ts.map +1 -1
- package/dist/validations/access-checker/wearables.js +9 -10
- package/dist/validations/access-checker/wearables.js.map +1 -1
- package/dist/validations/content.d.ts +6 -6
- package/dist/validations/content.d.ts.map +1 -1
- package/dist/validations/content.js +44 -50
- package/dist/validations/content.js.map +1 -1
- package/dist/validations/entity-structure.d.ts +2 -2
- package/dist/validations/entity-structure.d.ts.map +1 -1
- package/dist/validations/entity-structure.js +10 -11
- package/dist/validations/entity-structure.js.map +1 -1
- package/dist/validations/index.d.ts +9 -4
- package/dist/validations/index.d.ts.map +1 -1
- package/dist/validations/index.js +7 -7
- package/dist/validations/index.js.map +1 -1
- package/dist/validations/ipfs-hashing.d.ts +2 -2
- package/dist/validations/ipfs-hashing.d.ts.map +1 -1
- package/dist/validations/ipfs-hashing.js +8 -10
- package/dist/validations/ipfs-hashing.js.map +1 -1
- package/dist/validations/items/emotes.d.ts +4 -4
- package/dist/validations/items/emotes.d.ts.map +1 -1
- package/dist/validations/items/emotes.js +22 -24
- package/dist/validations/items/emotes.js.map +1 -1
- package/dist/validations/items/items.d.ts +4 -4
- package/dist/validations/items/items.d.ts.map +1 -1
- package/dist/validations/items/items.js +54 -55
- package/dist/validations/items/items.js.map +1 -1
- package/dist/validations/items/wearables.d.ts +4 -3
- package/dist/validations/items/wearables.d.ts.map +1 -1
- package/dist/validations/items/wearables.js +16 -17
- package/dist/validations/items/wearables.js.map +1 -1
- package/dist/validations/metadata-schema.d.ts +2 -2
- package/dist/validations/metadata-schema.d.ts.map +1 -1
- package/dist/validations/metadata-schema.js +17 -21
- package/dist/validations/metadata-schema.js.map +1 -1
- package/dist/validations/profile.d.ts +6 -6
- package/dist/validations/profile.d.ts.map +1 -1
- package/dist/validations/profile.js +55 -63
- package/dist/validations/profile.js.map +1 -1
- package/dist/validations/scene.d.ts +3 -3
- package/dist/validations/scene.d.ts.map +1 -1
- package/dist/validations/scene.js +5 -7
- package/dist/validations/scene.js.map +1 -1
- package/dist/validations/signature.d.ts +2 -2
- package/dist/validations/signature.d.ts.map +1 -1
- package/dist/validations/signature.js +6 -8
- package/dist/validations/signature.js.map +1 -1
- package/dist/validations/size.d.ts +2 -2
- package/dist/validations/size.d.ts.map +1 -1
- package/dist/validations/size.js +28 -29
- package/dist/validations/size.js.map +1 -1
- package/dist/validations/validations.d.ts +9 -9
- package/dist/validations/validations.d.ts.map +1 -1
- package/dist/validations/validations.js +34 -38
- package/dist/validations/validations.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeploymentToValidate } from '../..';
|
|
2
|
+
import { ContentValidatorComponents, ValidateFn } from '../../types';
|
|
2
3
|
/** Validate wearable representations are referencing valid content */
|
|
3
|
-
export declare
|
|
4
|
+
export declare function wearableRepresentationContent(components: ContentValidatorComponents, deployment: DeploymentToValidate): Promise<import("../..").ValidationResponse>;
|
|
4
5
|
/**
|
|
5
6
|
* Validate that given wearable deployment includes the thumbnail and doesn't exceed file sizes
|
|
6
7
|
* * @public
|
|
7
8
|
*/
|
|
8
|
-
export declare const wearable:
|
|
9
|
+
export declare const wearable: ValidateFn;
|
|
9
10
|
//# sourceMappingURL=wearables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wearables.d.ts","sourceRoot":"","sources":["../../../src/validations/items/wearables.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"wearables.d.ts","sourceRoot":"","sources":["../../../src/validations/items/wearables.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,0BAA0B,EAAM,UAAU,EAAoB,MAAM,aAAa,CAAA;AAG1F,sEAAsE;AACtE,wBAAsB,6BAA6B,CACjD,UAAU,EAAE,0BAA0B,EACtC,UAAU,EAAE,oBAAoB,+CAgBjC;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,UAAsF,CAAA"}
|
|
@@ -5,28 +5,27 @@ const schemas_1 = require("@dcl/schemas");
|
|
|
5
5
|
const types_1 = require("../../types");
|
|
6
6
|
const validations_1 = require("../validations");
|
|
7
7
|
/** Validate wearable representations are referencing valid content */
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
for (const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return (0, types_1.validationFailed)(`Representation content: '${representationContent}' is not one of the content files`);
|
|
21
|
-
}
|
|
8
|
+
async function wearableRepresentationContent(components, deployment) {
|
|
9
|
+
const { entity } = deployment;
|
|
10
|
+
const wearableMetadata = entity.metadata;
|
|
11
|
+
const representations = wearableMetadata?.data?.representations;
|
|
12
|
+
if (!representations || representations.length === 0)
|
|
13
|
+
return (0, types_1.validationFailed)('No wearable representations found');
|
|
14
|
+
if (!entity.content || entity.content.length === 0)
|
|
15
|
+
return (0, types_1.validationFailed)('No content found');
|
|
16
|
+
for (const representation of representations) {
|
|
17
|
+
for (const representationContent of representation.contents) {
|
|
18
|
+
if (!entity.content.find((content) => content.file === representationContent)) {
|
|
19
|
+
return (0, types_1.validationFailed)(`Representation content: '${representationContent}' is not one of the content files`);
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
return types_1.OK;
|
|
25
22
|
}
|
|
26
|
-
|
|
23
|
+
return types_1.OK;
|
|
24
|
+
}
|
|
25
|
+
exports.wearableRepresentationContent = wearableRepresentationContent;
|
|
27
26
|
/**
|
|
28
27
|
* Validate that given wearable deployment includes the thumbnail and doesn't exceed file sizes
|
|
29
28
|
* * @public
|
|
30
29
|
*/
|
|
31
|
-
exports.wearable = (0, validations_1.
|
|
30
|
+
exports.wearable = (0, validations_1.validateIfTypeMatches)(schemas_1.EntityType.WEARABLE, wearableRepresentationContent);
|
|
32
31
|
//# sourceMappingURL=wearables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wearables.js","sourceRoot":"","sources":["../../../src/validations/items/wearables.ts"],"names":[],"mappings":";;;AAAA,0CAAmD;
|
|
1
|
+
{"version":3,"file":"wearables.js","sourceRoot":"","sources":["../../../src/validations/items/wearables.ts"],"names":[],"mappings":";;;AAAA,0CAAmD;AAEnD,uCAA0F;AAC1F,gDAAsD;AAEtD,sEAAsE;AAC/D,KAAK,UAAU,6BAA6B,CACjD,UAAsC,EACtC,UAAgC;IAEhC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;IAC7B,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAoB,CAAA;IACpD,MAAM,eAAe,GAAG,gBAAgB,EAAE,IAAI,EAAE,eAAe,CAAA;IAC/D,IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAA,wBAAgB,EAAC,mCAAmC,CAAC,CAAA;IAClH,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAA,wBAAgB,EAAC,kBAAkB,CAAC,CAAA;IAE/F,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE;QAC5C,KAAK,MAAM,qBAAqB,IAAI,cAAc,CAAC,QAAQ,EAAE;YAC3D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,qBAAqB,CAAC,EAAE;gBAC7E,OAAO,IAAA,wBAAgB,EAAC,4BAA4B,qBAAqB,mCAAmC,CAAC,CAAA;aAC9G;SACF;KACF;IACD,OAAO,UAAE,CAAA;AACX,CAAC;AAlBD,sEAkBC;AAED;;;GAGG;AACU,QAAA,QAAQ,GAAe,IAAA,mCAAqB,EAAC,oBAAU,CAAC,QAAQ,EAAE,6BAA6B,CAAC,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const metadata:
|
|
1
|
+
import { ValidateFn } from '../types';
|
|
2
|
+
export declare const metadata: ValidateFn;
|
|
3
3
|
//# sourceMappingURL=metadata-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-schema.d.ts","sourceRoot":"","sources":["../../src/validations/metadata-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAwD,UAAU,EAAoB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"metadata-schema.d.ts","sourceRoot":"","sources":["../../src/validations/metadata-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAwD,UAAU,EAAoB,MAAM,UAAU,CAAA;AA0D7G,eAAO,MAAM,QAAQ,EAAE,UAGtB,CAAA"}
|
|
@@ -10,17 +10,15 @@ const validations_1 = require("./validations");
|
|
|
10
10
|
* Validate entities metadata against its corresponding schema
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return types_1.OK;
|
|
19
|
-
}
|
|
20
|
-
const errors = validator.errors?.map(($) => '' + $.message) || [];
|
|
21
|
-
return (0, types_1.validationFailed)(`The metadata for this entity type (${deployment.entity.type}) is not valid.`, ...errors);
|
|
13
|
+
function metadataSchemaIsValid(components, deployment) {
|
|
14
|
+
const { type, metadata } = deployment.entity;
|
|
15
|
+
const validator = ADR51_1.entityParameters[type].validate;
|
|
16
|
+
if (validator(metadata)) {
|
|
17
|
+
return types_1.OK;
|
|
22
18
|
}
|
|
23
|
-
|
|
19
|
+
const errors = validator.errors?.map(($) => '' + $.message) || [];
|
|
20
|
+
return (0, types_1.validationFailed)(`The metadata for this entity type (${deployment.entity.type}) is not valid.`, ...errors);
|
|
21
|
+
}
|
|
24
22
|
/**
|
|
25
23
|
* This map contains one ADR timeline per entity type. In a timeline, each element has
|
|
26
24
|
* a number and a timestamp. The number corresponds to the number of an ADR and the timestamp
|
|
@@ -40,15 +38,13 @@ const ADRMetadataVersionTimelines = {
|
|
|
40
38
|
/**
|
|
41
39
|
* This validation is being ran only for emotes currently
|
|
42
40
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
exports.metadata = (0, validations_1.validationGroup)((0, validations_1.validationAfterADR45)(metadataSchemaIsValid), (0, validations_1.validationAfterADR74)((0, validations_1.validationForType)(schemas_1.EntityType.EMOTE, metadataVersionIsCorrectForTimestamp)));
|
|
41
|
+
function metadataVersionIsCorrectForTimestamp(components, deployment) {
|
|
42
|
+
const entity = deployment.entity;
|
|
43
|
+
const adrNumber = ADRMetadataVersionTimelines[entity.type].find((v) => v.timestamp < entity.timestamp)?.number;
|
|
44
|
+
const expectedDataField = `${entity.type}DataADR${adrNumber}`;
|
|
45
|
+
return `${expectedDataField}` in deployment.entity.metadata
|
|
46
|
+
? types_1.OK
|
|
47
|
+
: (0, types_1.validationFailed)(`'emoteData' field version is incorrect. It must be: '${expectedDataField} but it is: ${deployment.entity.metadata} `);
|
|
48
|
+
}
|
|
49
|
+
exports.metadata = (0, validations_1.validateAll)((0, validations_1.validateAfterADR45)(metadataSchemaIsValid), (0, validations_1.validateAfterADR74)((0, validations_1.validateIfTypeMatches)(schemas_1.EntityType.EMOTE, metadataVersionIsCorrectForTimestamp)));
|
|
54
50
|
//# sourceMappingURL=metadata-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-schema.js","sourceRoot":"","sources":["../../src/validations/metadata-schema.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AACzC,oCAA6G;AAC7G,mCAA0C;AAC1C,6CAA+C;AAC/C,+
|
|
1
|
+
{"version":3,"file":"metadata-schema.js","sourceRoot":"","sources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CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC9G,MAAM,iBAAiB,GAAG,GAAG,MAAM,CAAC,IAAI,UAAU,SAAS,EAAE,CAAA;IAC7D,OAAO,GAAG,iBAAiB,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,QAAQ;QACzD,CAAC,CAAC,UAAE;QACJ,CAAC,CAAC,IAAA,wBAAgB,EACd,wDAAwD,iBAAiB,eAAe,UAAU,CAAC,MAAM,CAAC,QAAQ,GAAG,CACtH,CAAA;AACP,CAAC;AAEY,QAAA,QAAQ,GAAe,IAAA,yBAAW,EAC7C,IAAA,gCAAkB,EAAC,qBAAqB,CAAC,EACzC,IAAA,gCAAkB,EAAC,IAAA,mCAAqB,EAAC,oBAAU,CAAC,KAAK,EAAE,oCAAoC,CAAC,CAAC,CAClG,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValidateFn } from '../types';
|
|
2
2
|
export declare const isOldEmote: (wearable: string) => boolean;
|
|
3
|
-
export declare const faceThumbnail:
|
|
4
|
-
export declare const wearableUrns:
|
|
5
|
-
export declare const emoteUrns:
|
|
6
|
-
export declare const profileMustHaveEmotes:
|
|
3
|
+
export declare const faceThumbnail: ValidateFn;
|
|
4
|
+
export declare const wearableUrns: ValidateFn;
|
|
5
|
+
export declare const emoteUrns: ValidateFn;
|
|
6
|
+
export declare const profileMustHaveEmotes: ValidateFn;
|
|
7
7
|
/**
|
|
8
8
|
* Validate that given profile deployment includes the face256 file with the correct size
|
|
9
9
|
* * @public
|
|
10
10
|
*/
|
|
11
|
-
export declare const profile:
|
|
11
|
+
export declare const profile: ValidateFn;
|
|
12
12
|
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/validations/profile.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/validations/profile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwD,UAAU,EAAoB,MAAM,UAAU,CAAA;AAY7G,eAAO,MAAM,UAAU,aAAc,MAAM,KAAG,OAAqC,CAAA;AAEnF,eAAO,MAAM,aAAa,EAAE,UA8B3B,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,UAgB1B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,UAmBvB,CAAA;AAYD,eAAO,MAAM,qBAAqB,EAAE,UAOnC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,UAGrB,CAAA"}
|
|
@@ -13,73 +13,67 @@ const validations_1 = require("./validations");
|
|
|
13
13
|
const defaultThumbnailSize = 256;
|
|
14
14
|
const isOldEmote = (wearable) => /^[a-z]+$/i.test(wearable);
|
|
15
15
|
exports.isOldEmote = isOldEmote;
|
|
16
|
-
exports.faceThumbnail = (0, validations_1.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
errors.push(`Couldn't validate thumbnail size for file 'face256'`);
|
|
38
|
-
}
|
|
39
|
-
else if (width !== defaultThumbnailSize || height !== defaultThumbnailSize) {
|
|
40
|
-
errors.push(`Invalid face256 thumbnail image size (width = ${width} / height = ${height})`);
|
|
41
|
-
}
|
|
16
|
+
exports.faceThumbnail = (0, validations_1.validateAfterADR45)(async (components, deployment) => {
|
|
17
|
+
const errors = [];
|
|
18
|
+
const allAvatars = deployment.entity.metadata?.avatars ?? [];
|
|
19
|
+
for (const avatar of allAvatars) {
|
|
20
|
+
const hash = avatar.avatar.snapshots.face256;
|
|
21
|
+
if (!hash)
|
|
22
|
+
return (0, types_1.validationFailed)(`Couldn't find hash for face256 thumbnail file with name: 'face256'`);
|
|
23
|
+
const isAlreadyStored = (await components.externalCalls.isContentStoredAlready([hash])).get(hash) ?? false;
|
|
24
|
+
if (isAlreadyStored) {
|
|
25
|
+
return types_1.OK;
|
|
26
|
+
}
|
|
27
|
+
// check size
|
|
28
|
+
const thumbnailBuffer = deployment.files.get(hash);
|
|
29
|
+
if (!thumbnailBuffer)
|
|
30
|
+
return (0, types_1.validationFailed)(`Couldn't find thumbnail file with hash: ${hash}`);
|
|
31
|
+
try {
|
|
32
|
+
const { width, height, format } = await (0, sharp_1.default)(thumbnailBuffer).metadata();
|
|
33
|
+
if (!format || format !== 'png')
|
|
34
|
+
errors.push(`Invalid or unknown image format. Only 'PNG' format is accepted.`);
|
|
35
|
+
if (!width || !height) {
|
|
36
|
+
errors.push(`Couldn't validate thumbnail size for file 'face256'`);
|
|
42
37
|
}
|
|
43
|
-
|
|
44
|
-
errors.push(`
|
|
38
|
+
else if (width !== defaultThumbnailSize || height !== defaultThumbnailSize) {
|
|
39
|
+
errors.push(`Invalid face256 thumbnail image size (width = ${width} / height = ${height})`);
|
|
45
40
|
}
|
|
46
41
|
}
|
|
47
|
-
|
|
42
|
+
catch (e) {
|
|
43
|
+
errors.push(`Couldn't parse face256 thumbnail, please check image format.`);
|
|
44
|
+
}
|
|
48
45
|
}
|
|
46
|
+
return errors.length > 0 ? (0, types_1.validationFailed)(...errors) : types_1.OK;
|
|
49
47
|
});
|
|
50
|
-
exports.wearableUrns = (0, validations_1.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
for (const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return (0, types_1.validationFailed)(`Each profile wearable pointer should be a urn, for example (urn:decentraland:{protocol}:collections-v2:{contract(0x[a-fA-F0-9]+)}:{name}). Invalid pointer: (${pointer})`);
|
|
60
|
-
}
|
|
48
|
+
exports.wearableUrns = (0, validations_1.validateAfterADR75)(async (components, deployment) => {
|
|
49
|
+
const allAvatars = deployment.entity.metadata?.avatars ?? [];
|
|
50
|
+
for (const avatar of allAvatars) {
|
|
51
|
+
for (const pointer of avatar.avatar.wearables) {
|
|
52
|
+
if ((0, exports.isOldEmote)(pointer))
|
|
53
|
+
continue;
|
|
54
|
+
const parsed = await (0, urn_resolver_1.parseUrn)(pointer);
|
|
55
|
+
if (!parsed)
|
|
56
|
+
return (0, types_1.validationFailed)(`Each profile wearable pointer should be a urn, for example (urn:decentraland:{protocol}:collections-v2:{contract(0x[a-fA-F0-9]+)}:{name}). Invalid pointer: (${pointer})`);
|
|
61
57
|
}
|
|
62
|
-
return types_1.OK;
|
|
63
58
|
}
|
|
59
|
+
return types_1.OK;
|
|
64
60
|
});
|
|
65
|
-
exports.emoteUrns = (0, validations_1.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return (0, types_1.validationFailed)(`The slot ${slot} of the emote ${urn} must be a number between 0 and 9 (inclusive).`);
|
|
78
|
-
}
|
|
61
|
+
exports.emoteUrns = (0, validations_1.validateAfterADR74)(async (components, deployment) => {
|
|
62
|
+
const allAvatars = deployment.entity.metadata?.avatars ?? [];
|
|
63
|
+
for (const avatar of allAvatars) {
|
|
64
|
+
const allEmotes = avatar.avatar.emotes ?? [];
|
|
65
|
+
for (const { slot, urn } of allEmotes) {
|
|
66
|
+
if ((0, exports.isOldEmote)(urn))
|
|
67
|
+
continue;
|
|
68
|
+
const parsed = await (0, urn_resolver_1.parseUrn)(urn);
|
|
69
|
+
if (!parsed)
|
|
70
|
+
return (0, types_1.validationFailed)(`Each profile emote pointer should be a urn, for example (urn:decentraland:{protocol}:collections-v2:{contract(0x[a-fA-F0-9]+)}:{name}). Invalid pointer: (${urn})`);
|
|
71
|
+
if (slot < 0 || slot > 9) {
|
|
72
|
+
return (0, types_1.validationFailed)(`The slot ${slot} of the emote ${urn} must be a number between 0 and 9 (inclusive).`);
|
|
79
73
|
}
|
|
80
74
|
}
|
|
81
|
-
return types_1.OK;
|
|
82
75
|
}
|
|
76
|
+
return types_1.OK;
|
|
83
77
|
});
|
|
84
78
|
function profileHasEmotes(deployment) {
|
|
85
79
|
const allAvatars = deployment.entity.metadata?.avatars ?? [];
|
|
@@ -90,17 +84,15 @@ function profileHasEmotes(deployment) {
|
|
|
90
84
|
}
|
|
91
85
|
return false;
|
|
92
86
|
}
|
|
93
|
-
exports.profileMustHaveEmotes = (0, validations_1.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return (0, types_1.validationFailed)('Profile must have emotes after ADR 74.');
|
|
97
|
-
}
|
|
98
|
-
return types_1.OK;
|
|
87
|
+
exports.profileMustHaveEmotes = (0, validations_1.validateAfterADR74)(async (components, deployment) => {
|
|
88
|
+
if (!profileHasEmotes(deployment)) {
|
|
89
|
+
return (0, types_1.validationFailed)('Profile must have emotes after ADR 74.');
|
|
99
90
|
}
|
|
91
|
+
return types_1.OK;
|
|
100
92
|
});
|
|
101
93
|
/**
|
|
102
94
|
* Validate that given profile deployment includes the face256 file with the correct size
|
|
103
95
|
* * @public
|
|
104
96
|
*/
|
|
105
|
-
exports.profile = (0, validations_1.
|
|
97
|
+
exports.profile = (0, validations_1.validateIfTypeMatches)(schemas_1.EntityType.PROFILE, (0, validations_1.validateAll)(exports.faceThumbnail, exports.wearableUrns, exports.emoteUrns, exports.profileMustHaveEmotes));
|
|
106
98
|
//# sourceMappingURL=profile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/validations/profile.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAiD;AACjD,oDAA4C;AAC5C,kDAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/validations/profile.ts"],"names":[],"mapp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,EACtD,oBAAU,CAAC,OAAO,EAClB,IAAA,yBAAW,EAAC,qBAAa,EAAE,oBAAY,EAAE,iBAAS,EAAE,6BAAqB,CAAC,CAC3E,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValidateFn } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Validate that given scene deployment does not contain worldConfiguration section
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export declare const noWorldsConfiguration:
|
|
6
|
+
export declare const noWorldsConfiguration: ValidateFn;
|
|
7
7
|
/**
|
|
8
8
|
* Validate that given scene deployment is valid
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
|
-
export declare const scene:
|
|
11
|
+
export declare const scene: ValidateFn;
|
|
12
12
|
//# sourceMappingURL=scene.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../../src/validations/scene.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../../src/validations/scene.ts"],"names":[],"mappings":"AACA,OAAO,EAAwD,UAAU,EAAoB,MAAM,UAAU,CAAA;AAO7G;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,UAOnC,CAAA;AACD;;;GAGG;AACH,eAAO,MAAM,KAAK,EAAE,UAA2E,CAAA"}
|
|
@@ -11,17 +11,15 @@ function sceneHasWorldConfiguration(deployment) {
|
|
|
11
11
|
* Validate that given scene deployment does not contain worldConfiguration section
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
|
-
exports.noWorldsConfiguration = (0, validations_1.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return (0, types_1.validationFailed)('Scenes cannot have worldConfiguration section after ADR 173.');
|
|
18
|
-
}
|
|
19
|
-
return types_1.OK;
|
|
14
|
+
exports.noWorldsConfiguration = (0, validations_1.validateAfterADR173)(async (components, deployment) => {
|
|
15
|
+
if (sceneHasWorldConfiguration(deployment)) {
|
|
16
|
+
return (0, types_1.validationFailed)('Scenes cannot have worldConfiguration section after ADR 173.');
|
|
20
17
|
}
|
|
18
|
+
return types_1.OK;
|
|
21
19
|
});
|
|
22
20
|
/**
|
|
23
21
|
* Validate that given scene deployment is valid
|
|
24
22
|
* @public
|
|
25
23
|
*/
|
|
26
|
-
exports.scene = (0, validations_1.
|
|
24
|
+
exports.scene = (0, validations_1.validateIfTypeMatches)(schemas_1.EntityType.SCENE, exports.noWorldsConfiguration);
|
|
27
25
|
//# sourceMappingURL=scene.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene.js","sourceRoot":"","sources":["../../src/validations/scene.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"scene.js","sourceRoot":"","sources":["../../src/validations/scene.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AACzC,oCAA6G;AAC7G,+CAA0E;AAE1E,SAAS,0BAA0B,CAAC,UAAgC;IAClE,OAAO,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,KAAK,SAAS,CAAA;AACrE,CAAC;AAED;;;GAGG;AACU,QAAA,qBAAqB,GAAe,IAAA,iCAAmB,EAClE,KAAK,EAAE,UAAsC,EAAE,UAAgC,EAAE,EAAE;IACjF,IAAI,0BAA0B,CAAC,UAAU,CAAC,EAAE;QAC1C,OAAO,IAAA,wBAAgB,EAAC,8DAA8D,CAAC,CAAA;KACxF;IACD,OAAO,UAAE,CAAA;AACX,CAAC,CACF,CAAA;AACD;;;GAGG;AACU,QAAA,KAAK,GAAe,IAAA,mCAAqB,EAAC,oBAAU,CAAC,KAAK,EAAE,6BAAqB,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentValidatorComponents, DeploymentToValidate } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Validate that the signature belongs to the Ethereum address
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
6
|
+
export declare function signature(components: ContentValidatorComponents, deployment: DeploymentToValidate): Promise<import("../types").ValidationResponse>;
|
|
7
7
|
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/validations/signature.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/validations/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAwB,MAAM,UAAU,CAAA;AAEjG;;;GAGG;AACH,wBAAsB,SAAS,CAAC,UAAU,EAAE,0BAA0B,EAAE,UAAU,EAAE,oBAAoB,kDAIvG"}
|
|
@@ -6,12 +6,10 @@ const types_1 = require("../types");
|
|
|
6
6
|
* Validate that the signature belongs to the Ethereum address
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
};
|
|
9
|
+
async function signature(components, deployment) {
|
|
10
|
+
const { entity, auditInfo } = deployment;
|
|
11
|
+
const validationResult = await components.externalCalls.validateSignature(entity.id, auditInfo, entity.timestamp);
|
|
12
|
+
return !validationResult.ok ? (0, types_1.validationFailed)('The signature is invalid. ' + validationResult.message) : types_1.OK;
|
|
13
|
+
}
|
|
14
|
+
exports.signature = signature;
|
|
17
15
|
//# sourceMappingURL=signature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../src/validations/signature.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../src/validations/signature.ts"],"names":[],"mappings":";;;AAAA,oCAAiG;AAEjG;;;GAGG;AACI,KAAK,UAAU,SAAS,CAAC,UAAsC,EAAE,UAAgC;IACtG,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAA;IACxC,MAAM,gBAAgB,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;IACjH,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAA,wBAAgB,EAAC,4BAA4B,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAE,CAAA;AAC9G,CAAC;AAJD,8BAIC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentValidatorComponents, DeploymentToValidate } from '../types';
|
|
2
2
|
/** Validate that the full request size is within limits
|
|
3
3
|
*
|
|
4
4
|
* ADR 45: After given TIMESTAMP will also include previous deployments in the validation
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export declare
|
|
7
|
+
export declare function size(components: ContentValidatorComponents, deployment: DeploymentToValidate): Promise<import("../types").ValidationResponse>;
|
|
8
8
|
//# sourceMappingURL=size.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../src/validations/size.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../src/validations/size.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAwB,MAAM,UAAU,CAAA;AAIjG;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,UAAU,EAAE,0BAA0B,EAAE,UAAU,EAAE,oBAAoB,kDA2BlG"}
|
package/dist/validations/size.js
CHANGED
|
@@ -10,34 +10,33 @@ const timestamps_1 = require("./timestamps");
|
|
|
10
10
|
* ADR 45: After given TIMESTAMP will also include previous deployments in the validation
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return (0, types_1.validationFailed)(`Type ${entity.type} is not supported yet`);
|
|
22
|
-
}
|
|
23
|
-
const maxSizeInBytes = maxSizeInMB * 1024 * 1024;
|
|
24
|
-
let totalSize = 0;
|
|
25
|
-
if (entity.timestamp > timestamps_1.ADR_45_TIMESTAMP) {
|
|
26
|
-
const result = await (0, _1.calculateDeploymentSize)(deployment, externalCalls);
|
|
27
|
-
if (typeof result === 'string')
|
|
28
|
-
return (0, types_1.validationFailed)(result);
|
|
29
|
-
totalSize = result;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
totalSize = Array.from(deployment.files.values()).reduce((acc, file) => acc + file.byteLength, 0);
|
|
33
|
-
}
|
|
34
|
-
const sizePerPointer = totalSize / entity.pointers.length;
|
|
35
|
-
if (sizePerPointer > maxSizeInBytes) {
|
|
36
|
-
errors = [
|
|
37
|
-
`The deployment is too big. The maximum allowed size per pointer is ${maxSizeInMB} MB for ${entity.type}. You can upload up to ${entity.pointers.length * maxSizeInBytes} bytes but you tried to upload ${totalSize}.`
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
return errors.length > 0 ? (0, types_1.validationFailed)(...errors) : types_1.OK;
|
|
13
|
+
async function size(components, deployment) {
|
|
14
|
+
const { entity } = deployment;
|
|
15
|
+
if (entity.timestamp <= timestamps_1.LEGACY_CONTENT_MIGRATION_TIMESTAMP)
|
|
16
|
+
return types_1.OK;
|
|
17
|
+
const maxSizeInMB = ADR51_1.entityParameters[entity.type].maxSizeInMB;
|
|
18
|
+
let errors = [];
|
|
19
|
+
if (!maxSizeInMB) {
|
|
20
|
+
return (0, types_1.validationFailed)(`Type ${entity.type} is not supported yet`);
|
|
41
21
|
}
|
|
42
|
-
|
|
22
|
+
const maxSizeInBytes = maxSizeInMB * 1024 * 1024;
|
|
23
|
+
let totalSize = 0;
|
|
24
|
+
if (entity.timestamp > timestamps_1.ADR_45_TIMESTAMP) {
|
|
25
|
+
const result = await (0, _1.calculateDeploymentSize)(deployment, components.externalCalls);
|
|
26
|
+
if (typeof result === 'string')
|
|
27
|
+
return (0, types_1.validationFailed)(result);
|
|
28
|
+
totalSize = result;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
totalSize = Array.from(deployment.files.values()).reduce((acc, file) => acc + file.byteLength, 0);
|
|
32
|
+
}
|
|
33
|
+
const sizePerPointer = totalSize / entity.pointers.length;
|
|
34
|
+
if (sizePerPointer > maxSizeInBytes) {
|
|
35
|
+
errors = [
|
|
36
|
+
`The deployment is too big. The maximum allowed size per pointer is ${maxSizeInMB} MB for ${entity.type}. You can upload up to ${entity.pointers.length * maxSizeInBytes} bytes but you tried to upload ${totalSize}.`
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
return errors.length > 0 ? (0, types_1.validationFailed)(...errors) : types_1.OK;
|
|
40
|
+
}
|
|
41
|
+
exports.size = size;
|
|
43
42
|
//# sourceMappingURL=size.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size.js","sourceRoot":"","sources":["../../src/validations/size.ts"],"names":[],"mappings":";;;AAAA,wBAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"size.js","sourceRoot":"","sources":["../../src/validations/size.ts"],"names":[],"mappings":";;;AAAA,wBAA2C;AAC3C,oCAAiG;AACjG,mCAA0C;AAC1C,6CAAmF;AAEnF;;;;GAIG;AACI,KAAK,UAAU,IAAI,CAAC,UAAsC,EAAE,UAAgC;IACjG,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;IAC7B,IAAI,MAAM,CAAC,SAAS,IAAI,+CAAkC;QAAE,OAAO,UAAE,CAAA;IAErE,MAAM,WAAW,GAAG,wBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAA;IAC7D,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
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
2
|
+
import { DeploymentToValidate, ValidateFn } from '../types';
|
|
3
|
+
export declare function validateAll(...validationFns: ValidateFn[]): ValidateFn;
|
|
4
|
+
export declare function validateIfConditionMet(condition: (deployment: DeploymentToValidate) => boolean | Promise<boolean>, validateFn: ValidateFn): ValidateFn;
|
|
5
|
+
export declare function validateAfterADR45(validate: ValidateFn): ValidateFn;
|
|
6
|
+
export declare function validateAfterADR75(validate: ValidateFn): ValidateFn;
|
|
7
|
+
export declare function validateAfterADR74(validate: ValidateFn): ValidateFn;
|
|
8
|
+
export declare function validateAfterADR158(validate: ValidateFn): ValidateFn;
|
|
9
|
+
export declare function validateAfterADR173(validate: ValidateFn): ValidateFn;
|
|
10
|
+
export declare function validateIfTypeMatches(entityType: EntityType, validate: ValidateFn): ValidateFn;
|
|
11
11
|
//# sourceMappingURL=validations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../src/validations/validations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAA8B,oBAAoB,EAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../src/validations/validations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAA8B,oBAAoB,EAAM,UAAU,EAAE,MAAM,UAAU,CAAA;AAS3F,wBAAgB,WAAW,CAAC,GAAG,aAAa,EAAE,UAAU,EAAE,GAAG,UAAU,CAQtE;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,CAAC,UAAU,EAAE,oBAAoB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAC3E,UAAU,EAAE,UAAU,GACrB,UAAU,CAQZ;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,CAEnE;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,CAEnE;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,CAEnE;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,CAEpE;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,CAEpE;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,cAEjF"}
|