@dcl/content-validator 2.0.0 → 2.0.1-20220609170141.commit-082ae9e
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/content-validator.api.json +205 -9
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/the-graph-client/the-graph-client.d.ts +6 -0
- package/dist/the-graph-client/the-graph-client.d.ts.map +1 -0
- package/dist/the-graph-client/the-graph-client.js +210 -0
- package/dist/the-graph-client/the-graph-client.js.map +1 -0
- package/dist/types.d.ts +25 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validations/access-checker/profiles.d.ts.map +1 -1
- package/dist/validations/access-checker/profiles.js +42 -1
- package/dist/validations/access-checker/profiles.js.map +1 -1
- package/dist/validations/index.d.ts +6 -1
- package/dist/validations/index.d.ts.map +1 -1
- package/dist/validations/index.js +9 -2
- package/dist/validations/index.js.map +1 -1
- package/dist/validations/profile.d.ts +1 -0
- package/dist/validations/profile.d.ts.map +1 -1
- package/dist/validations/profile.js +41 -2
- package/dist/validations/profile.js.map +1 -1
- package/dist/validations/wearable.js +1 -1
- package/package.json +9 -3
|
@@ -191,6 +191,27 @@
|
|
|
191
191
|
"endIndex": 2
|
|
192
192
|
}
|
|
193
193
|
},
|
|
194
|
+
{
|
|
195
|
+
"kind": "Variable",
|
|
196
|
+
"canonicalReference": "@dcl/content-validator!ADR_XXX_TIMESTAMP:var",
|
|
197
|
+
"docComment": "/**\n * 1655294400000 = 2022-06-15T12:00:00Z\n *\n * @public\n */\n",
|
|
198
|
+
"excerptTokens": [
|
|
199
|
+
{
|
|
200
|
+
"kind": "Content",
|
|
201
|
+
"text": "ADR_XXX_TIMESTAMP: "
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"kind": "Content",
|
|
205
|
+
"text": "number"
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"releaseTag": "Public",
|
|
209
|
+
"name": "ADR_XXX_TIMESTAMP",
|
|
210
|
+
"variableTypeTokenRange": {
|
|
211
|
+
"startIndex": 1,
|
|
212
|
+
"endIndex": 2
|
|
213
|
+
}
|
|
214
|
+
},
|
|
194
215
|
{
|
|
195
216
|
"kind": "Variable",
|
|
196
217
|
"canonicalReference": "@dcl/content-validator!calculateDeploymentSize:var",
|
|
@@ -362,6 +383,15 @@
|
|
|
362
383
|
"text": "ILoggerComponent",
|
|
363
384
|
"canonicalReference": "@well-known-components/interfaces!ILoggerComponent:type"
|
|
364
385
|
},
|
|
386
|
+
{
|
|
387
|
+
"kind": "Content",
|
|
388
|
+
"text": ";\n theGraphClient: "
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
"kind": "Reference",
|
|
392
|
+
"text": "TheGraphClient",
|
|
393
|
+
"canonicalReference": "@dcl/content-validator!TheGraphClient:type"
|
|
394
|
+
},
|
|
365
395
|
{
|
|
366
396
|
"kind": "Content",
|
|
367
397
|
"text": ";\n externalCalls: "
|
|
@@ -384,7 +414,51 @@
|
|
|
384
414
|
"name": "ContentValidatorComponents",
|
|
385
415
|
"typeTokenRange": {
|
|
386
416
|
"startIndex": 1,
|
|
387
|
-
"endIndex":
|
|
417
|
+
"endIndex": 8
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
"kind": "Variable",
|
|
422
|
+
"canonicalReference": "@dcl/content-validator!createTheGraphClient:var",
|
|
423
|
+
"docComment": "/**\n * @public\n */\n",
|
|
424
|
+
"excerptTokens": [
|
|
425
|
+
{
|
|
426
|
+
"kind": "Content",
|
|
427
|
+
"text": "createTheGraphClient: "
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"kind": "Content",
|
|
431
|
+
"text": "(components: "
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"kind": "Reference",
|
|
435
|
+
"text": "Pick",
|
|
436
|
+
"canonicalReference": "!Pick:type"
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"kind": "Content",
|
|
440
|
+
"text": "<"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"kind": "Reference",
|
|
444
|
+
"text": "ContentValidatorComponents",
|
|
445
|
+
"canonicalReference": "@dcl/content-validator!ContentValidatorComponents:type"
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
"kind": "Content",
|
|
449
|
+
"text": ", 'logs' | 'externalCalls'>) => "
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
"kind": "Reference",
|
|
453
|
+
"text": "TheGraphClient",
|
|
454
|
+
"canonicalReference": "@dcl/content-validator!TheGraphClient:type"
|
|
455
|
+
}
|
|
456
|
+
],
|
|
457
|
+
"releaseTag": "Public",
|
|
458
|
+
"name": "createTheGraphClient",
|
|
459
|
+
"variableTypeTokenRange": {
|
|
460
|
+
"startIndex": 1,
|
|
461
|
+
"endIndex": 7
|
|
388
462
|
}
|
|
389
463
|
},
|
|
390
464
|
{
|
|
@@ -416,7 +490,7 @@
|
|
|
416
490
|
},
|
|
417
491
|
{
|
|
418
492
|
"kind": "Content",
|
|
419
|
-
"text": ", 'externalCalls' | 'logs'>) => "
|
|
493
|
+
"text": ", 'externalCalls' | 'logs' | 'theGraphClient'>) => "
|
|
420
494
|
},
|
|
421
495
|
{
|
|
422
496
|
"kind": "Reference",
|
|
@@ -621,7 +695,7 @@
|
|
|
621
695
|
},
|
|
622
696
|
{
|
|
623
697
|
"kind": "Content",
|
|
624
|
-
"text": ";\n subgraphs: {\n L1: {\n landManager: string;\n blocks: string;\n collections: string;\n };\n L2: {\n blocks: string;\n collections: string;\n thirdPartyRegistry: string;\n };\n };\n}"
|
|
698
|
+
"text": ";\n subgraphs: {\n L1: {\n landManager: string;\n blocks: string;\n collections: string;\n ensOwner: string;\n };\n L2: {\n blocks: string;\n collections: string;\n thirdPartyRegistry: string;\n };\n };\n}"
|
|
625
699
|
},
|
|
626
700
|
{
|
|
627
701
|
"kind": "Content",
|
|
@@ -909,6 +983,128 @@
|
|
|
909
983
|
"endIndex": 8
|
|
910
984
|
}
|
|
911
985
|
},
|
|
986
|
+
{
|
|
987
|
+
"kind": "TypeAlias",
|
|
988
|
+
"canonicalReference": "@dcl/content-validator!TheGraphClient:type",
|
|
989
|
+
"docComment": "/**\n * @public\n */\n",
|
|
990
|
+
"excerptTokens": [
|
|
991
|
+
{
|
|
992
|
+
"kind": "Content",
|
|
993
|
+
"text": "export declare type TheGraphClient = "
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
"kind": "Content",
|
|
997
|
+
"text": "{\n checkForNamesOwnershipWithTimestamp: (ethAddress: "
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
"kind": "Reference",
|
|
1001
|
+
"text": "EthAddress",
|
|
1002
|
+
"canonicalReference": "@dcl/schemas!EthAddress:type"
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
"kind": "Content",
|
|
1006
|
+
"text": ", namesToCheck: string[], timestamp: number) => "
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
"kind": "Reference",
|
|
1010
|
+
"text": "Promise",
|
|
1011
|
+
"canonicalReference": "!Promise:interface"
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
"kind": "Content",
|
|
1015
|
+
"text": "<"
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
"kind": "Reference",
|
|
1019
|
+
"text": "Set",
|
|
1020
|
+
"canonicalReference": "!Set:interface"
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
"kind": "Content",
|
|
1024
|
+
"text": "<string>>;\n checkForWearablesOwnershipWithTimestamp: (ethAddress: "
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
"kind": "Reference",
|
|
1028
|
+
"text": "EthAddress",
|
|
1029
|
+
"canonicalReference": "@dcl/schemas!EthAddress:type"
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
"kind": "Content",
|
|
1033
|
+
"text": ", wearableIdsToCheck: string[], timestamp: number) => "
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
"kind": "Reference",
|
|
1037
|
+
"text": "Promise",
|
|
1038
|
+
"canonicalReference": "!Promise:interface"
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
"kind": "Content",
|
|
1042
|
+
"text": "<"
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
"kind": "Reference",
|
|
1046
|
+
"text": "Set",
|
|
1047
|
+
"canonicalReference": "!Set:interface"
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
"kind": "Content",
|
|
1051
|
+
"text": "<string>>;\n findBlocksForTimestamp: (subgraph: keyof "
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
"kind": "Reference",
|
|
1055
|
+
"text": "URLs",
|
|
1056
|
+
"canonicalReference": "@dcl/content-validator!URLs:type"
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
"kind": "Content",
|
|
1060
|
+
"text": ", timestamp: number) => "
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
"kind": "Reference",
|
|
1064
|
+
"text": "Promise",
|
|
1065
|
+
"canonicalReference": "!Promise:interface"
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
"kind": "Content",
|
|
1069
|
+
"text": "<{\n blockNumberAtDeployment: number | undefined;\n blockNumberFiveMinBeforeDeployment: number | undefined;\n }>;\n}"
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
"kind": "Content",
|
|
1073
|
+
"text": ";"
|
|
1074
|
+
}
|
|
1075
|
+
],
|
|
1076
|
+
"releaseTag": "Public",
|
|
1077
|
+
"name": "TheGraphClient",
|
|
1078
|
+
"typeTokenRange": {
|
|
1079
|
+
"startIndex": 1,
|
|
1080
|
+
"endIndex": 18
|
|
1081
|
+
}
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
"kind": "TypeAlias",
|
|
1085
|
+
"canonicalReference": "@dcl/content-validator!URLs:type",
|
|
1086
|
+
"docComment": "/**\n * @public\n */\n",
|
|
1087
|
+
"excerptTokens": [
|
|
1088
|
+
{
|
|
1089
|
+
"kind": "Content",
|
|
1090
|
+
"text": "export declare type URLs = "
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
"kind": "Content",
|
|
1094
|
+
"text": "{\n ensSubgraph: string;\n blocksSubgraph: string;\n maticBlocksSubgraph: string;\n collectionsSubgraph: string;\n maticCollectionsSubgraph: string;\n thirdPartyRegistrySubgraph: string;\n}"
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
"kind": "Content",
|
|
1098
|
+
"text": ";"
|
|
1099
|
+
}
|
|
1100
|
+
],
|
|
1101
|
+
"releaseTag": "Public",
|
|
1102
|
+
"name": "URLs",
|
|
1103
|
+
"typeTokenRange": {
|
|
1104
|
+
"startIndex": 1,
|
|
1105
|
+
"endIndex": 2
|
|
1106
|
+
}
|
|
1107
|
+
},
|
|
912
1108
|
{
|
|
913
1109
|
"kind": "Variable",
|
|
914
1110
|
"canonicalReference": "@dcl/content-validator!validateInRow:var",
|
|
@@ -920,21 +1116,21 @@
|
|
|
920
1116
|
},
|
|
921
1117
|
{
|
|
922
1118
|
"kind": "Content",
|
|
923
|
-
"text": "(
|
|
1119
|
+
"text": "(components: "
|
|
924
1120
|
},
|
|
925
1121
|
{
|
|
926
1122
|
"kind": "Reference",
|
|
927
|
-
"text": "
|
|
928
|
-
"canonicalReference": "@dcl/content-validator!
|
|
1123
|
+
"text": "ContentValidatorComponents",
|
|
1124
|
+
"canonicalReference": "@dcl/content-validator!ContentValidatorComponents:type"
|
|
929
1125
|
},
|
|
930
1126
|
{
|
|
931
1127
|
"kind": "Content",
|
|
932
|
-
"text": ",
|
|
1128
|
+
"text": ", deployment: "
|
|
933
1129
|
},
|
|
934
1130
|
{
|
|
935
1131
|
"kind": "Reference",
|
|
936
|
-
"text": "
|
|
937
|
-
"canonicalReference": "@dcl/content-validator!
|
|
1132
|
+
"text": "DeploymentToValidate",
|
|
1133
|
+
"canonicalReference": "@dcl/content-validator!DeploymentToValidate:type"
|
|
938
1134
|
},
|
|
939
1135
|
{
|
|
940
1136
|
"kind": "Content",
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export * from './validations';
|
|
|
5
5
|
* Creates a validator instance with given external calls.
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export declare const createValidator: (components: Pick<ContentValidatorComponents, 'externalCalls' | 'logs'>) => Validator;
|
|
8
|
+
export declare const createValidator: (components: Pick<ContentValidatorComponents, 'externalCalls' | 'logs' | 'theGraphClient'>) => Validator;
|
|
9
|
+
export { createTheGraphClient } from './the-graph-client/the-graph-client';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAM,SAAS,EAAE,MAAM,SAAS,CAAA;AAGnE,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAE7B;;;GAGG;AACH,eAAO,MAAM,eAAe,eACd,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAM,SAAS,EAAE,MAAM,SAAS,CAAA;AAGnE,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAE7B;;;GAGG;AACH,eAAO,MAAM,eAAe,eACd,KACV,0BAA0B,EAC1B,eAAe,GAAG,MAAM,GAAG,gBAAgB,CAC5C,KACA,SAeF,CAAA;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createValidator = void 0;
|
|
17
|
+
exports.createTheGraphClient = exports.createValidator = void 0;
|
|
18
18
|
const types_1 = require("./types");
|
|
19
19
|
const validations_1 = require("./validations");
|
|
20
20
|
__exportStar(require("./types"), exports);
|
|
@@ -39,4 +39,6 @@ const createValidator = (components) => {
|
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
exports.createValidator = createValidator;
|
|
42
|
+
var the_graph_client_1 = require("./the-graph-client/the-graph-client");
|
|
43
|
+
Object.defineProperty(exports, "createTheGraphClient", { enumerable: true, get: function () { return the_graph_client_1.createTheGraphClient; } });
|
|
42
44
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAmE;AACnE,+CAA2C;AAE3C,0CAAuB;AACvB,gDAA6B;AAE7B;;;GAGG;AACI,MAAM,eAAe,GAAG,CAC7B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAmE;AACnE,+CAA2C;AAE3C,0CAAuB;AACvB,gDAA6B;AAE7B;;;GAGG;AACI,MAAM,eAAe,GAAG,CAC7B,UAGC,EACU,EAAE;IACb,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAA;IAE1D,OAAO;QACL,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;YAC7B,KAAK,MAAM,UAAU,IAAI,yBAAW,EAAE;gBACpC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;gBAChE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;oBACd,IAAI,CAAC,KAAK,CAAC,uBAAuB,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;oBAC9D,OAAO,MAAM,CAAA;iBACd;aACF;YACD,OAAO,UAAE,CAAA;QACX,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AApBY,QAAA,eAAe,mBAoB3B;AAED,wEAA0E;AAAjE,wHAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContentValidatorComponents, TheGraphClient } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export declare const createTheGraphClient: (components: Pick<ContentValidatorComponents, 'logs' | 'externalCalls'>) => TheGraphClient;
|
|
6
|
+
//# sourceMappingURL=the-graph-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"the-graph-client.d.ts","sourceRoot":"","sources":["../../src/the-graph-client/the-graph-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAQ,MAAM,UAAU,CAAA;AAG3E;;GAEG;AACH,eAAO,MAAM,oBAAoB,eACnB,KAAK,0BAA0B,EAAE,MAAM,GAAG,eAAe,CAAC,KACrE,cAiRF,CAAA"}
|
|
@@ -0,0 +1,210 @@
|
|
|
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.createTheGraphClient = void 0;
|
|
7
|
+
const ms_1 = __importDefault(require("ms"));
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
const createTheGraphClient = (components) => {
|
|
12
|
+
const logger = components.logs.getLogger('TheGraphClient');
|
|
13
|
+
const urls = {
|
|
14
|
+
collectionsSubgraph: components.externalCalls.subgraphs.L1.collections,
|
|
15
|
+
blocksSubgraph: components.externalCalls.subgraphs.L1.blocks,
|
|
16
|
+
maticBlocksSubgraph: components.externalCalls.subgraphs.L2.blocks,
|
|
17
|
+
ensSubgraph: components.externalCalls.subgraphs.L1.ensOwner,
|
|
18
|
+
maticCollectionsSubgraph: components.externalCalls.subgraphs.L2.collections,
|
|
19
|
+
thirdPartyRegistrySubgraph: components.externalCalls.subgraphs.L2.thirdPartyRegistry
|
|
20
|
+
};
|
|
21
|
+
const checkForNamesOwnershipWithTimestamp = async (ethAddress, namesToCheck, timestamp) => {
|
|
22
|
+
const blocks = await findBlocksForTimestamp('blocksSubgraph', timestamp);
|
|
23
|
+
const blocksToCheck = [
|
|
24
|
+
blocks.blockNumberAtDeployment ?? -1,
|
|
25
|
+
blocks.blockNumberFiveMinBeforeDeployment ?? -1
|
|
26
|
+
].filter((block) => block !== -1);
|
|
27
|
+
const namesQuery = `{` +
|
|
28
|
+
blocksToCheck
|
|
29
|
+
.map((block) => getNamesForBlockFragment(block, ethAddress, namesToCheck))
|
|
30
|
+
.join('\n') +
|
|
31
|
+
`}`;
|
|
32
|
+
const mapper = (response) => Object.entries(response).reduce((set, [, names]) => {
|
|
33
|
+
names.forEach(({ name }) => set.add(name));
|
|
34
|
+
return set;
|
|
35
|
+
}, new Set());
|
|
36
|
+
const query = {
|
|
37
|
+
description: 'check for names ownership',
|
|
38
|
+
subgraph: 'ensSubgraph',
|
|
39
|
+
query: namesQuery,
|
|
40
|
+
mapper
|
|
41
|
+
};
|
|
42
|
+
return runQuery(query, {});
|
|
43
|
+
};
|
|
44
|
+
const getNamesForBlockFragment = (block, ethAddress, names) => {
|
|
45
|
+
const nameList = names.map((name) => `"${name}"`).join(',');
|
|
46
|
+
return `
|
|
47
|
+
B${block}: nfts(
|
|
48
|
+
block: { number: ${block} }
|
|
49
|
+
where: { owner: "${ethAddress}", category: ens, name_in: [${nameList}] }
|
|
50
|
+
first: 1000
|
|
51
|
+
) {
|
|
52
|
+
name
|
|
53
|
+
}`;
|
|
54
|
+
};
|
|
55
|
+
const checkForWearablesOwnershipWithTimestamp = async (ethAddress, wearableIdsToCheck, timestamp) => {
|
|
56
|
+
const ethereumWearablesOwnersPromise = getOwnersByWearableWithTimestamp(ethAddress, wearableIdsToCheck, timestamp, 'blocksSubgraph', 'collectionsSubgraph');
|
|
57
|
+
const maticWearablesOwnersPromise = getOwnersByWearableWithTimestamp(ethAddress, wearableIdsToCheck, timestamp, 'maticBlocksSubgraph', 'maticCollectionsSubgraph');
|
|
58
|
+
const [ethereumWearablesOwners, maticWearablesOwners] = await Promise.all([
|
|
59
|
+
ethereumWearablesOwnersPromise,
|
|
60
|
+
maticWearablesOwnersPromise
|
|
61
|
+
]);
|
|
62
|
+
return new Set([...ethereumWearablesOwners, ...maticWearablesOwners]);
|
|
63
|
+
};
|
|
64
|
+
const getOwnersByWearableWithTimestamp = async (ethAddress, wearableIdsToCheck, timestamp, blocksSubgraph, collectionsSubgraph) => {
|
|
65
|
+
const blocks = await findBlocksForTimestamp(blocksSubgraph, timestamp);
|
|
66
|
+
const blocksToCheck = [
|
|
67
|
+
blocks.blockNumberAtDeployment ?? -1,
|
|
68
|
+
blocks.blockNumberFiveMinBeforeDeployment ?? -1
|
|
69
|
+
].filter((block) => block !== -1);
|
|
70
|
+
const subgraphQuery = `{` +
|
|
71
|
+
blocksToCheck
|
|
72
|
+
.map((block) => getWearablesForBlockFragment(block, ethAddress, wearableIdsToCheck))
|
|
73
|
+
.join('\n') +
|
|
74
|
+
`}`;
|
|
75
|
+
const mapper = (response) => Object.entries(response).reduce((set, [, names]) => {
|
|
76
|
+
names.forEach(({ urn }) => set.add(urn));
|
|
77
|
+
return set;
|
|
78
|
+
}, new Set());
|
|
79
|
+
const query = {
|
|
80
|
+
description: 'check for wearables ownership',
|
|
81
|
+
subgraph: collectionsSubgraph,
|
|
82
|
+
query: subgraphQuery,
|
|
83
|
+
mapper
|
|
84
|
+
};
|
|
85
|
+
return runQuery(query, {});
|
|
86
|
+
};
|
|
87
|
+
const getWearablesForBlockFragment = (block, ethAddress, wearableIds) => {
|
|
88
|
+
const urnList = wearableIds.map((wearableId) => `"${wearableId}"`).join(',');
|
|
89
|
+
return `
|
|
90
|
+
B${block}: nfts(
|
|
91
|
+
block: {number: ${block}}
|
|
92
|
+
where: {
|
|
93
|
+
owner: "${ethAddress}",
|
|
94
|
+
searchItemType_in: ["wearable_v1", "wearable_v2", "smart_wearable_v1", "emote_v1"],
|
|
95
|
+
urn_in: [${urnList}]
|
|
96
|
+
}
|
|
97
|
+
first: 1000
|
|
98
|
+
) {
|
|
99
|
+
urn
|
|
100
|
+
}`;
|
|
101
|
+
};
|
|
102
|
+
const runQuery = async (query, variables) => {
|
|
103
|
+
try {
|
|
104
|
+
const response = await components.externalCalls.queryGraph(urls[query.subgraph], query.query, variables);
|
|
105
|
+
return query.mapper(response);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
logger.error(`Failed to execute the following query to the subgraph ${urls[query.subgraph]} ${query.description}'.`, error);
|
|
109
|
+
throw new Error('Internal server error');
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
// When we want to find a block for a specific timestamp, we define an access window. This means that
|
|
113
|
+
// we will place will try to find the closes block to the timestamp, but only if it's within the window
|
|
114
|
+
const ACCESS_WINDOW_IN_SECONDS = (0, ms_1.default)('15s') / 1000;
|
|
115
|
+
const getWindowFromTimestamp = (timestamp) => {
|
|
116
|
+
const windowMin = timestamp - Math.floor(ACCESS_WINDOW_IN_SECONDS / 2);
|
|
117
|
+
const windowMax = timestamp + Math.ceil(ACCESS_WINDOW_IN_SECONDS / 2);
|
|
118
|
+
return {
|
|
119
|
+
max: windowMax,
|
|
120
|
+
min: windowMin
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
const findBlocksForTimestamp = async (subgraph, timestamp) => {
|
|
124
|
+
const query = {
|
|
125
|
+
description: 'fetch blocks for timestamp',
|
|
126
|
+
subgraph: subgraph,
|
|
127
|
+
query: QUERY_BLOCKS_FOR_TIMESTAMP,
|
|
128
|
+
mapper: (response) => {
|
|
129
|
+
// To get the deployment's block number, we check the one immediately after the entity's timestamp. Since it could not exist, we default to the one immediately before.
|
|
130
|
+
const blockNumberAtDeployment = response.after[0]?.number ?? response.before[0]?.number;
|
|
131
|
+
const blockNumberFiveMinBeforeDeployment = response.fiveMinAfter[0]?.number ?? response.fiveMinBefore[0]?.number;
|
|
132
|
+
if (blockNumberAtDeployment === undefined &&
|
|
133
|
+
blockNumberFiveMinBeforeDeployment === undefined) {
|
|
134
|
+
throw new Error(`Failed to find blocks for the specific timestamp`);
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
blockNumberAtDeployment: !!blockNumberAtDeployment
|
|
138
|
+
? parseInt(blockNumberAtDeployment)
|
|
139
|
+
: undefined,
|
|
140
|
+
blockNumberFiveMinBeforeDeployment: !!blockNumberFiveMinBeforeDeployment
|
|
141
|
+
? parseInt(blockNumberFiveMinBeforeDeployment)
|
|
142
|
+
: undefined
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const timestampSec = Math.ceil(timestamp / 1000);
|
|
147
|
+
const timestamp5MinAgo = timestampSec - 60 * 5;
|
|
148
|
+
const window = getWindowFromTimestamp(timestampSec);
|
|
149
|
+
const window5MinAgo = getWindowFromTimestamp(timestamp5MinAgo);
|
|
150
|
+
try {
|
|
151
|
+
return await runQuery(query, {
|
|
152
|
+
timestamp: timestampSec,
|
|
153
|
+
timestampMax: window.max,
|
|
154
|
+
timestampMin: window.min,
|
|
155
|
+
timestamp5Min: timestamp5MinAgo,
|
|
156
|
+
timestamp5MinMax: window5MinAgo.max,
|
|
157
|
+
timestamp5MinMin: window5MinAgo.min
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
logger.error(`Error fetching the block number for timestamp`, {
|
|
162
|
+
timestamp,
|
|
163
|
+
error: e?.message
|
|
164
|
+
});
|
|
165
|
+
throw e;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
checkForNamesOwnershipWithTimestamp,
|
|
170
|
+
checkForWearablesOwnershipWithTimestamp,
|
|
171
|
+
findBlocksForTimestamp
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
exports.createTheGraphClient = createTheGraphClient;
|
|
175
|
+
const QUERY_BLOCKS_FOR_TIMESTAMP = `
|
|
176
|
+
query getBlockForTimestamp($timestamp: Int!, $timestampMin: Int!, $timestampMax: Int!, $timestamp5Min: Int!, $timestamp5MinMax: Int!, $timestamp5MinMin: Int!) {
|
|
177
|
+
before: blocks(
|
|
178
|
+
where: {timestamp_lte: $timestamp, timestamp_gte: $timestampMin}
|
|
179
|
+
first: 1
|
|
180
|
+
orderBy: timestamp
|
|
181
|
+
orderDirection: desc
|
|
182
|
+
) {
|
|
183
|
+
number
|
|
184
|
+
}
|
|
185
|
+
after: blocks(
|
|
186
|
+
where: {timestamp_gte: $timestamp, timestamp_lte: $timestampMax}
|
|
187
|
+
first: 1
|
|
188
|
+
orderBy: timestamp
|
|
189
|
+
orderDirection: asc
|
|
190
|
+
) {
|
|
191
|
+
number
|
|
192
|
+
}
|
|
193
|
+
fiveMinBefore: blocks(
|
|
194
|
+
where: {timestamp_lte: $timestamp5Min, timestamp_gte: $timestamp5MinMin}
|
|
195
|
+
first: 1
|
|
196
|
+
orderBy: timestamp
|
|
197
|
+
orderDirection: desc
|
|
198
|
+
) {
|
|
199
|
+
number
|
|
200
|
+
}
|
|
201
|
+
fiveMinAfter: blocks(
|
|
202
|
+
where: {timestamp_gte: $timestamp5Min, timestamp_lte: $timestamp5MinMax}
|
|
203
|
+
first: 1
|
|
204
|
+
orderBy: timestamp
|
|
205
|
+
orderDirection: asc
|
|
206
|
+
) {
|
|
207
|
+
number
|
|
208
|
+
}
|
|
209
|
+
}`;
|
|
210
|
+
//# sourceMappingURL=the-graph-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"the-graph-client.js","sourceRoot":"","sources":["../../src/the-graph-client/the-graph-client.ts"],"names":[],"mappings":";;;;;;AAEA,4CAAmB;AAEnB;;GAEG;AACI,MAAM,oBAAoB,GAAG,CAClC,UAAsE,EACtD,EAAE;IAClB,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAA;IAE1D,MAAM,IAAI,GAAS;QACjB,mBAAmB,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,WAAW;QACtE,cAAc,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM;QAC5D,mBAAmB,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM;QACjE,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ;QAC3D,wBAAwB,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,WAAW;QAC3E,0BAA0B,EACxB,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,kBAAkB;KAC3D,CAAA;IAED,MAAM,mCAAmC,GAAG,KAAK,EAC/C,UAAsB,EACtB,YAAsB,EACtB,SAAiB,EACK,EAAE;QACxB,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAA;QAExE,MAAM,aAAa,GAAa;YAC9B,MAAM,CAAC,uBAAuB,IAAI,CAAC,CAAC;YACpC,MAAM,CAAC,kCAAkC,IAAI,CAAC,CAAC;SAChD,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,C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AAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAA;QAChD,MAAM,gBAAgB,GAAG,YAAY,GAAG,EAAE,GAAG,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAA;QACnD,MAAM,aAAa,GAAG,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;QAE9D,IAAI;YACF,OAAO,MAAM,QAAQ,CAAC,KAAK,EAAE;gBAC3B,SAAS,EAAE,YAAY;gBACvB,YAAY,EAAE,MAAM,CAAC,GAAG;gBACxB,YAAY,EAAE,MAAM,CAAC,GAAG;gBACxB,aAAa,EAAE,gBAAgB;gBAC/B,gBAAgB,EAAE,aAAa,CAAC,GAAG;gBACnC,gBAAgB,EAAE,aAAa,CAAC,GAAG;aACpC,CAAC,CAAA;SACH;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,+CAA+C,EAAE;gBAC5D,SAAS;gBACT,KAAK,EAAG,CAAS,EAAE,OAAO;aAC3B,CAAC,CAAA;YACF,MAAM,CAAC,CAAA;SACR;IACH,CAAC,CAAA;IAED,OAAO;QACL,mCAAmC;QACnC,uCAAuC;QACvC,sBAAsB;KACvB,CAAA;AACH,CAAC,CAAA;AAnRY,QAAA,oBAAoB,wBAmRhC;AAED,MAAM,0BAA0B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCjC,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthChain, Entity } from '@dcl/schemas';
|
|
1
|
+
import { AuthChain, Entity, EthAddress } from '@dcl/schemas';
|
|
2
2
|
import { ILoggerComponent } from '@well-known-components/interfaces';
|
|
3
3
|
/**
|
|
4
4
|
* @public
|
|
@@ -53,6 +53,7 @@ export declare type ExternalCalls = {
|
|
|
53
53
|
landManager: string;
|
|
54
54
|
blocks: string;
|
|
55
55
|
collections: string;
|
|
56
|
+
ensOwner: string;
|
|
56
57
|
};
|
|
57
58
|
L2: {
|
|
58
59
|
blocks: string;
|
|
@@ -109,12 +110,35 @@ export declare const conditionalValidation: (condition: ConditionalValidation) =
|
|
|
109
110
|
* @public
|
|
110
111
|
*/
|
|
111
112
|
export declare const fromErrors: (...errors: Errors) => ValidationResponse;
|
|
113
|
+
/**
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export declare type URLs = {
|
|
117
|
+
ensSubgraph: string;
|
|
118
|
+
blocksSubgraph: string;
|
|
119
|
+
maticBlocksSubgraph: string;
|
|
120
|
+
collectionsSubgraph: string;
|
|
121
|
+
maticCollectionsSubgraph: string;
|
|
122
|
+
thirdPartyRegistrySubgraph: string;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
export declare type TheGraphClient = {
|
|
128
|
+
checkForNamesOwnershipWithTimestamp: (ethAddress: EthAddress, namesToCheck: string[], timestamp: number) => Promise<Set<string>>;
|
|
129
|
+
checkForWearablesOwnershipWithTimestamp: (ethAddress: EthAddress, wearableIdsToCheck: string[], timestamp: number) => Promise<Set<string>>;
|
|
130
|
+
findBlocksForTimestamp: (subgraph: keyof URLs, timestamp: number) => Promise<{
|
|
131
|
+
blockNumberAtDeployment: number | undefined;
|
|
132
|
+
blockNumberFiveMinBeforeDeployment: number | undefined;
|
|
133
|
+
}>;
|
|
134
|
+
};
|
|
112
135
|
/**
|
|
113
136
|
* Components that can be used to validate deployments.
|
|
114
137
|
* @public
|
|
115
138
|
*/
|
|
116
139
|
export declare type ContentValidatorComponents = {
|
|
117
140
|
logs: ILoggerComponent;
|
|
141
|
+
theGraphClient: TheGraphClient;
|
|
118
142
|
externalCalls: ExternalCalls;
|
|
119
143
|
};
|
|
120
144
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","source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,cAAc,CAAA;IAC9B,aAAa,EAAE,aAAa,CAAA;CAC7B,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAsHA;;GAEG;AACU,QAAA,EAAE,GAAuB,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;AAElD;;GAEG;AACI,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAe,EAAsB,EAAE,CAAC,CAAC;IAC3E,EAAE,EAAE,KAAK;IACT,MAAM,EAAE,KAAK;CACd,CAAC,CAAA;AAHW,QAAA,gBAAgB,oBAG3B;AAEF;;GAEG;AACI,MAAM,qBAAqB,GAAG,CACnC,SAAgC,EACpB,EAAE,CAAC,CAAC;IAChB,QAAQ,EAAE,KAAK,EACb,UAAsC,EACtC,UAAgC,EAChC,EAAE;QACF,IAAI;YACF,OAAO,MAAM,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;YACxD,sEAAsE;SACvE;QAAC,OAAO,GAAQ,EAAE;YACjB,OAAO,IAAA,wBAAgB,EAAC,sBAAsB,GAAG,EAAE,CAAC,CAAA;SACrD;IACH,CAAC;CACF,CAAC,CAAA;AAdW,QAAA,qBAAqB,yBAchC;AAEF;;GAEG;AACI,MAAM,UAAU,GAAG,CAAC,GAAG,MAAc,EAAsB,EAAE,CAAC,CAAC;IACpE,EAAE,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;CAC/C,CAAC,CAAA;AAHW,QAAA,UAAU,cAGrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/profiles.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,UAAU,EAAoB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../src/validations/access-checker/profiles.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,UAAU,EAAoB,MAAM,aAAa,CAAA;AAK9D;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,UA+DtB,CAAA"}
|
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.profiles = void 0;
|
|
4
4
|
const schemas_1 = require("@dcl/schemas");
|
|
5
5
|
const types_1 = require("../../types");
|
|
6
|
+
const urn_resolver_1 = require("@dcl/urn-resolver");
|
|
7
|
+
const index_1 = require("../index");
|
|
6
8
|
/**
|
|
7
9
|
* Validate that the pointers are valid, and that the Ethereum address has write access to them
|
|
8
10
|
* @public
|
|
9
11
|
*/
|
|
10
12
|
exports.profiles = {
|
|
11
|
-
validate: async ({ externalCalls }, deployment) => {
|
|
13
|
+
validate: async ({ externalCalls, theGraphClient }, deployment) => {
|
|
12
14
|
const pointers = deployment.entity.pointers;
|
|
13
15
|
const ethAddress = externalCalls.ownerAddress(deployment.auditInfo);
|
|
14
16
|
if (pointers.length !== 1)
|
|
@@ -24,7 +26,46 @@ exports.profiles = {
|
|
|
24
26
|
else if (pointer !== ethAddress.toLowerCase()) {
|
|
25
27
|
return (0, types_1.validationFailed)(`You can only alter your own profile. The pointer address and the signer address are different (pointer:${pointer} signer: ${ethAddress.toLowerCase()}).`);
|
|
26
28
|
}
|
|
29
|
+
if (deployment.entity.timestamp < index_1.ADR_XXX_TIMESTAMP)
|
|
30
|
+
return types_1.OK;
|
|
31
|
+
const names = allNames(deployment.entity);
|
|
32
|
+
if (names.length > 0) {
|
|
33
|
+
const ownedNames = await theGraphClient.checkForNamesOwnershipWithTimestamp(ethAddress, names, deployment.entity.timestamp);
|
|
34
|
+
const notOwnedNames = names.filter((name) => !ownedNames.has(name));
|
|
35
|
+
if (notOwnedNames.length > 0)
|
|
36
|
+
return (0, types_1.validationFailed)(`The following names (${notOwnedNames}) are not owned by the address ${ethAddress.toLowerCase()}).`);
|
|
37
|
+
}
|
|
38
|
+
const wearableUrns = await allWearablesUrns(deployment.entity);
|
|
39
|
+
if (wearableUrns.length > 0) {
|
|
40
|
+
const ownedWearables = await theGraphClient.checkForWearablesOwnershipWithTimestamp(ethAddress, wearableUrns, deployment.entity.timestamp);
|
|
41
|
+
const notOwned = wearableUrns.filter((wearable) => !ownedWearables.has(wearable));
|
|
42
|
+
if (notOwned.length > 0)
|
|
43
|
+
return (0, types_1.validationFailed)(`The following wearables (${notOwned}) are not owned by the address ${ethAddress.toLowerCase()}).`);
|
|
44
|
+
}
|
|
27
45
|
return types_1.OK;
|
|
28
46
|
}
|
|
29
47
|
};
|
|
48
|
+
const allNames = (entity) => entity.metadata.avatars
|
|
49
|
+
.filter((avatar) => avatar.hasClaimedName)
|
|
50
|
+
.map((avatar) => avatar.name)
|
|
51
|
+
.filter((name) => name && name.trim().length > 0);
|
|
52
|
+
const isBaseAvatar = (wearable) => wearable.includes('base-avatars');
|
|
53
|
+
const translateWearablesIdFormat = async (wearableId) => {
|
|
54
|
+
if (!wearableId.startsWith('dcl://')) {
|
|
55
|
+
return wearableId;
|
|
56
|
+
}
|
|
57
|
+
const parsed = await (0, urn_resolver_1.parseUrn)(wearableId);
|
|
58
|
+
return parsed?.uri?.toString();
|
|
59
|
+
};
|
|
60
|
+
const allWearablesUrns = async (entity) => {
|
|
61
|
+
const allWearablesInProfilePromises = [];
|
|
62
|
+
for (const avatar of entity.metadata.avatars) {
|
|
63
|
+
for (const wearableId of avatar.avatar.wearables) {
|
|
64
|
+
if (!isBaseAvatar(wearableId)) {
|
|
65
|
+
allWearablesInProfilePromises.push(translateWearablesIdFormat(wearableId));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return (await Promise.all(allWearablesInProfilePromises)).filter((wearableId) => !!wearableId);
|
|
70
|
+
};
|
|
30
71
|
//# sourceMappingURL=profiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../../src/validations/access-checker/profiles.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../../src/validations/access-checker/profiles.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AACjD,uCAA8D;AAC9D,oDAA4C;AAE5C,oCAA4C;AAE5C;;;GAGG;AACU,QAAA,QAAQ,GAAe;IAClC,QAAQ,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE,UAAU,EAAE,EAAE;QAChE,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,EACrB,oEAAoE,QAAQ,EAAE,CAC/E,CAAA;QAEH,MAAM,OAAO,GAAW,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;QAEjD,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YACjC,IAAI,CAAC,aAAa,CAAC,4BAA4B,CAAC,UAAU,CAAC;gBACzD,OAAO,IAAA,wBAAgB,EACrB,sDAAsD,CACvD,CAAA;SACJ;aAAM,IAAI,CAAC,oBAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YACxC,OAAO,IAAA,wBAAgB,EACrB,oDAAoD,CACrD,CAAA;SACF;aAAM,IAAI,OAAO,KAAK,UAAU,CAAC,WAAW,EAAE,EAAE;YAC/C,OAAO,IAAA,wBAAgB,EACrB,0GAA0G,OAAO,YAAY,UAAU,CAAC,WAAW,EAAE,IA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AA"}
|
|
@@ -2,12 +2,17 @@ import { ContentValidatorComponents, DeploymentToValidate, ExternalCalls, Valida
|
|
|
2
2
|
/**
|
|
3
3
|
* @public
|
|
4
4
|
*/
|
|
5
|
-
export declare const validateInRow: (
|
|
5
|
+
export declare const validateInRow: (components: ContentValidatorComponents, deployment: DeploymentToValidate, ...validations: Validation[]) => Promise<ValidationResponse>;
|
|
6
6
|
/**
|
|
7
7
|
* 1652191200000 = 2022-05-10T14:00:00Z
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
10
|
export declare const ADR_45_TIMESTAMP: number;
|
|
11
|
+
/**
|
|
12
|
+
* 1655294400000 = 2022-06-15T12:00:00Z
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const ADR_XXX_TIMESTAMP: number;
|
|
11
16
|
/**
|
|
12
17
|
* DCL Launch Day
|
|
13
18
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,aAAa,EAEb,UAAU,EACV,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAWjB;;GAEG;AACH,eAAO,MAAM,aAAa,eACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,aAAa,EAEb,UAAU,EACV,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAWjB;;GAEG;AACH,eAAO,MAAM,aAAa,eACZ,0BAA0B,cAC1B,oBAAoB,kBAChB,UAAU,EAAE,KAC3B,QAAQ,kBAAkB,CAM5B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAEZ,CAAA;AAEjB;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAEb,CAAA;AAEjB;;;GAGG;AACH,eAAO,MAAM,kCAAkC,gBAAgB,CAAA;AAE/D;;GAEG;AACH,eAAO,MAAM,uBAAuB,eACtB,oBAAoB,iBACjB,aAAa,KAC3B,QAAQ,MAAM,GAAG,MAAM,CAgBzB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,mFAOtB,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,oBAAoB,+CAIvB,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,WAAW,uHAGd,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validations = exports.statelessValidations = exports.statefulValidations = exports.calculateDeploymentSize = exports.LEGACY_CONTENT_MIGRATION_TIMESTAMP = exports.ADR_45_TIMESTAMP = exports.validateInRow = void 0;
|
|
3
|
+
exports.validations = exports.statelessValidations = exports.statefulValidations = exports.calculateDeploymentSize = exports.LEGACY_CONTENT_MIGRATION_TIMESTAMP = exports.ADR_XXX_TIMESTAMP = exports.ADR_45_TIMESTAMP = exports.validateInRow = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const access_1 = require("./access-checker/access");
|
|
6
6
|
const content_1 = require("./content");
|
|
@@ -14,7 +14,7 @@ const wearable_1 = require("./wearable");
|
|
|
14
14
|
/**
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
|
-
const validateInRow = async (
|
|
17
|
+
const validateInRow = async (components, deployment, ...validations) => {
|
|
18
18
|
for (const validation of validations) {
|
|
19
19
|
const response = await validation.validate(components, deployment);
|
|
20
20
|
if (!response.ok)
|
|
@@ -30,6 +30,13 @@ exports.validateInRow = validateInRow;
|
|
|
30
30
|
exports.ADR_45_TIMESTAMP = process.env.ADR_45_TIMESTAMP
|
|
31
31
|
? parseInt(process.env.ADR_45_TIMESTAMP)
|
|
32
32
|
: 1652191200000;
|
|
33
|
+
/**
|
|
34
|
+
* 1655294400000 = 2022-06-15T12:00:00Z
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
exports.ADR_XXX_TIMESTAMP = process.env.ADR_XXX_TIMESTAMP
|
|
38
|
+
? parseInt(process.env.ADR_XXX_TIMESTAMP)
|
|
39
|
+
: 1655294400000;
|
|
33
40
|
/**
|
|
34
41
|
* DCL Launch Day
|
|
35
42
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validations/index.ts"],"names":[],"mappings":";;;AAAA,oCAOiB;AACjB,oDAAgD;AAChD,uCAAmC;AACnC,yDAAoD;AACpD,iDAA4C;AAC5C,uDAA4C;AAC5C,uCAAmC;AACnC,2CAAuC;AACvC,iCAA6B;AAC7B,yCAAqC;AAErC;;GAEG;AACI,MAAM,aAAa,GAAG,KAAK,EAChC,UAAgC,EAChC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validations/index.ts"],"names":[],"mappings":";;;AAAA,oCAOiB;AACjB,oDAAgD;AAChD,uCAAmC;AACnC,yDAAoD;AACpD,iDAA4C;AAC5C,uDAA4C;AAC5C,uCAAmC;AACnC,2CAAuC;AACvC,iCAA6B;AAC7B,yCAAqC;AAErC;;GAEG;AACI,MAAM,aAAa,GAAG,KAAK,EAChC,UAAsC,EACtC,UAAgC,EAChC,GAAG,WAAyB,EACC,EAAE;IAC/B,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;QAClE,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO,QAAQ,CAAA;KAClC;IACD,OAAO,UAAE,CAAA;AACX,CAAC,CAAA;AAVY,QAAA,aAAa,iBAUzB;AAED;;;GAGG;AACU,QAAA,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB;IAC1D,CAAC,CAAC,QAAQ,CAAC,OAAO,CAA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A,WAAW,GAAG;IACzB,GAAG,4BAAoB;IACvB,GAAG,2BAAmB;CACd,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/validations/profile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAM,UAAU,EAAoB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/validations/profile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAM,UAAU,EAAoB,MAAM,UAAU,CAAA;AA2B3D,eAAO,MAAM,aAAa,EAAE,UAmD3B,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,UAmB1B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,UAMrB,CAAA"}
|
|
@@ -3,13 +3,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.profile = exports.faceThumbnail = void 0;
|
|
6
|
+
exports.profile = exports.wearableUrns = exports.faceThumbnail = void 0;
|
|
7
7
|
const schemas_1 = require("@dcl/schemas");
|
|
8
8
|
const sharp_1 = __importDefault(require("sharp"));
|
|
9
9
|
const _1 = require(".");
|
|
10
10
|
const types_1 = require("../types");
|
|
11
|
+
const urn_resolver_1 = require("@dcl/urn-resolver");
|
|
11
12
|
/** Validate that given profile deployment includes a face256 thumbnail with valid size */
|
|
12
13
|
const defaultThumbnailSize = 256;
|
|
14
|
+
const allowList = new Set([
|
|
15
|
+
'fistpump',
|
|
16
|
+
'wave',
|
|
17
|
+
'robot',
|
|
18
|
+
'raiseHand',
|
|
19
|
+
'clap',
|
|
20
|
+
'money',
|
|
21
|
+
'kiss',
|
|
22
|
+
'hammer',
|
|
23
|
+
'hohoho',
|
|
24
|
+
'snowfall',
|
|
25
|
+
'dance',
|
|
26
|
+
'shrug',
|
|
27
|
+
'tik',
|
|
28
|
+
'tektonik',
|
|
29
|
+
'dontsee',
|
|
30
|
+
'dab',
|
|
31
|
+
'handsair',
|
|
32
|
+
'disco'
|
|
33
|
+
]);
|
|
13
34
|
exports.faceThumbnail = {
|
|
14
35
|
validate: async ({ externalCalls }, deployment) => {
|
|
15
36
|
if (deployment.entity.timestamp < _1.ADR_45_TIMESTAMP)
|
|
@@ -47,6 +68,24 @@ exports.faceThumbnail = {
|
|
|
47
68
|
return errors.length > 0 ? (0, types_1.validationFailed)(...errors) : types_1.OK;
|
|
48
69
|
}
|
|
49
70
|
};
|
|
71
|
+
exports.wearableUrns = {
|
|
72
|
+
validate: async (components, deployment) => {
|
|
73
|
+
if (deployment.entity.timestamp < _1.ADR_XXX_TIMESTAMP)
|
|
74
|
+
return types_1.OK;
|
|
75
|
+
const allAvatars = deployment.entity.metadata?.avatars ?? [];
|
|
76
|
+
for (const avatar of allAvatars) {
|
|
77
|
+
for (const pointer of avatar.avatar.wearables) {
|
|
78
|
+
if (allowList.has(pointer)) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const parsed = await (0, urn_resolver_1.parseUrn)(pointer);
|
|
82
|
+
if (!parsed)
|
|
83
|
+
return (0, types_1.validationFailed)(`Wearable pointers should be a urn, for example (urn:decentraland:{protocol}:collections-v2:{contract(0x[a-fA-F0-9]+)}:{name}). Invalid pointer: (${pointer})`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return types_1.OK;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
50
89
|
/**
|
|
51
90
|
* Validate that given profile deployment includes the face256 file with the correct size
|
|
52
91
|
* * @public
|
|
@@ -55,7 +94,7 @@ exports.profile = {
|
|
|
55
94
|
validate: async (components, deployment) => {
|
|
56
95
|
if (deployment.entity.type !== schemas_1.EntityType.PROFILE)
|
|
57
96
|
return types_1.OK;
|
|
58
|
-
return
|
|
97
|
+
return (0, _1.validateInRow)(components, deployment, exports.faceThumbnail, exports.wearableUrns);
|
|
59
98
|
}
|
|
60
99
|
};
|
|
61
100
|
//# sourceMappingURL=profile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/validations/profile.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAyC;AACzC,kDAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/validations/profile.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAyC;AACzC,kDAAyB;AACzB,wBAAsE;AACtE,oCAA2D;AAC3D,oDAA4C;AAE5C,0FAA0F;AAC1F,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAEhC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,UAAU;IACV,MAAM;IACN,OAAO;IACP,WAAW;IACX,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,OAAO;IACP,OAAO;IACP,KAAK;IACL,UAAU;IACV,SAAS;IACT,KAAK;IACL,UAAU;IACV,OAAO;CACR,CAAC,CAAA;AAEW,QAAA,aAAa,GAAe;IACvC,QAAQ,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,EAAE;QAChD,IAAI,UAAU,CAAC,MAAM,CAAC,SAAS,GAAG,mBAAgB;YAAE,OAAO,UAAE,CAAA;QAE7D,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,MAAM,UAAU,GAAU,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAA;QAEnE,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE;YAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAA;YAC5C,IAAI,CAAC,IAAI;gBACP,OAAO,IAAA,wBAAgB,EACrB,oEAAoE,CACrE,CAAA;YAEH,MAAM,eAAe,GACnB,CAAC,MAAM,aAA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AE9D,MAAM,UAAU,GAAU,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAA;QACnE,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE;YAC/B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;gBAC7C,IAAI,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;oBAC1B,SAAQ;iBACT;gBACD,MAAM,MAAM,GAAG,MAAM,IAAA,uBAAQ,EAAC,OAAO,CAAC,CAAA;gBACtC,IAAI,CAAC,MAAM;oBACT,OAAO,IAAA,wBAAgB,EACrB,oJAAoJ,OAAO,GAAG,CAC/J,CAAA;aACJ;SACF;QACD,OAAO,UAAE,CAAA;IACX,CAAC;CACF,CAAA;AAED;;;GAGG;AACU,QAAA,OAAO,GAAe;IACjC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE;QACzC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,oBAAU,CAAC,OAAO;YAAE,OAAO,UAAE,CAAA;QAE5D,OAAO,IAAA,gBAAa,EAAC,UAAU,EAAE,UAAU,EAAE,qBAAa,EAAE,oBAAY,CAAC,CAAA;IAC3E,CAAC;CACF,CAAA"}
|
|
@@ -104,7 +104,7 @@ exports.wearable = {
|
|
|
104
104
|
validate: async (components, deployment) => {
|
|
105
105
|
if (deployment.entity.type !== schemas_1.EntityType.WEARABLE)
|
|
106
106
|
return types_1.OK;
|
|
107
|
-
return (0, _1.validateInRow)(
|
|
107
|
+
return (0, _1.validateInRow)(components, deployment, exports.wearableRepresentationContent, exports.wearableThumbnail, exports.wearableSize);
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
110
|
//# sourceMappingURL=wearable.js.map
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/content-validator",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1-20220609170141.commit-082ae9e",
|
|
4
4
|
"description": "Catalyst content validations",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
+
"clean-api-extractor": "rm -rf node_modules/@microsoft/api-extractor/node_modules/typescript || true",
|
|
9
|
+
"api-extractor": "yarn clean-api-extractor && api-extractor run --local --verbose --diagnostics --typescript-compiler-folder ./node_modules/typescript",
|
|
10
|
+
"api-extractor-ci": "yarn clean-api-extractor && api-extractor run --typescript-compiler-folder ./node_modules/typescript",
|
|
11
|
+
"build": "tsc -p tsconfig.json",
|
|
8
12
|
"lint:check": "eslint '**/*.{js,ts}'",
|
|
9
|
-
"lint:fix": "eslint '**/*.{js,ts}' --fix"
|
|
13
|
+
"lint:fix": "eslint '**/*.{js,ts}' --fix",
|
|
14
|
+
"test": "jest --runInBand --detectOpenHandles --colors --coverage",
|
|
15
|
+
"test:watch": "jest --runInBand --detectOpenHandles --colors --watch"
|
|
10
16
|
},
|
|
11
17
|
"repository": {
|
|
12
18
|
"type": "git",
|
|
@@ -53,5 +59,5 @@
|
|
|
53
59
|
"files": [
|
|
54
60
|
"dist"
|
|
55
61
|
],
|
|
56
|
-
"commit": "
|
|
62
|
+
"commit": "082ae9ee580831372ebf80e4aa7e2e79be0549d9"
|
|
57
63
|
}
|